<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .hide {
            display: none;
        }
        .show {
            display: flex;
        }
        .erweima {
            width: 300px;
            height: 300px;
            background-color: pink;
            border: 1px solid red;
        }
    </style>
</head>

<body>
    <div class="erweima hide" id="er"></div>
    <input id="servien" type="button" value="显示">
    <script>
        let servien = document.getElementById("servien");
        let erweima = document.querySelector("div.erweima");
        console.log(erweima);
        servien.onclick = function(){
            if(this.value === "显示"){
                this.value = "隐藏";
                erweima.className = erweima.className.replace("hide","show");
            } else {
                this.value = "显示";
                erweima.className = erweima.className.replace("show","hide");
            }
        };
    </script>
</body>

</html>